#-*-coding:utf-8-*-
#-------------------------------------------------------------------------------
# Name:        invest
# Purpose:
#
# Author:      Robot of Fernando
#
# Created:     17-06-2015
# Copyright:   (c) Administrator 2015
# Licence:     <GPLV3>
#-------------------------------------------------------------------------------
import math
class Hole:
    def __init__(self,holeType):
        '注意类变量和对象变量的区别'
        self.holeName=''
        self.holeID=0
        self.holeType=-1
        self.elevation=-1.00
        self.Dep=-1.00
        self.layers=[]

class BoreHole(Hole):
    def __init__(self):
        Hole.__init__(self,1)
        self.waterLevel=-1
        self.soilPoints=[]
        self.bgPoints=[]
    @property
    def waterElevation(self):
        return self.elevation-self.waterLevel

    def AddPoint(self,xPoint):
        if type(xPoint) is SoilPoint:
            self.soilPoints.append(xPoint)
        elif type(xPoint) is BgPoint:
            self.bgPoints.append(xPoint)

class BGHOLE(Hole):
    '注意类变量和对象变量的区别'
    def __init__(self):
        Hole.__init__(self,1)
        self.bgPoints=[]
    def AddPoint(self,bgPoint):
        self.bgPoints.append(bgPoint)

class Layer:
    def __init__(self):
        self.layerNo=''
        self.layerName=''
        self.layerOrder=-1
        self.startDep=-1.0
        self.endDep=-1.0
        self.holeName=''
        self.BgPoints=[]
        self.SoilPoints=[]
    def AddBgPoint(self,xPoint):
        self.BgPoints.append(xPoint)
    def AddSoilPoint(self,xPoint):
        self.SoilPoints.append(xPoint)

class BGPOINT:
    '注意类变量和对象变量的区别'
    def __init__(self):
        self.pointID=0
        # startDep=0
        # endDep=0
        # midDep=(startDep+endDep)/2
        self.testDep=0.0
        self.holeName=""
        self.soilType=""
        self.clayContent=-1.0
        self.N=-1.0
        self.Wi=-1.0
        self.Di=-1.0
        self.inf=''
    @property
    def Ncr(self):
        N0=7
        BETA=0.80
        DW=0.50
        Ncr=-1.0
        ds=self.testDep
        cc=self.clayContent
        soilType=self.soilType
        if cc>=10:
            return '-'
        elif cc<=3:
            Ncr=N0*BETA*(math.log(0.6*ds+1.5)-0.1*DW)
            return round(Ncr,2)
        else:
            Ncr=N0*BETA*(math.log(0.6*ds+1.5)-0.1*DW)*math.sqrt(3/cc)
            return round(Ncr,2)
    @property
    def FLei(self):
        if self.Ncr=='-':
            return '-'
        elif self.Ncr<=self.N:
            return '-'
        elif self.Ncr>self.N:
            return round(self.N/self.Ncr,2)
    @property
    def ILei(self):
        if self.FLei=='-':
            return '-'
        else:
            return round((1-self.FLei)*self.Di*self.Wi,2)
    @property
    def LiqueFlag(self):
        if self.Ncr=='-':
            return '否'
        elif self.Ncr<=self.N:
            return '否'
        elif self.Ncr>self.N:
            return '是'